﻿Imports Entidades
Imports AccesoDatos
Public Class Negocio
    Private bd As New AccesoDatos.AccesoDatos
    Public Event ExistePersona(ByVal sender As Object, ByVal e As ExisteCartaEventArg)
    ''' <summary>
    ''' Obtiene la carta buscando por Id
    ''' </summary>
    ''' <param name="id"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function getCardById(ByVal id As String) As Carta
        Dim cartas = bd.Cartas
        Dim cards = From c In cartas
                       Where c.Id = id
                       Select c

        Return cards
    End Function
    ''' <summary>
    ''' Obtiene la carta o cartas buscando por nombre (Titulo)
    ''' </summary>
    ''' <param name="name"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function getCardsByName(ByVal name As String) As ObjectModel.ReadOnlyCollection(Of Carta)
        Dim cartas = bd.Cartas
        Dim cards = From c In cartas
                       Where c.Titulo.Contains(name)
                       Select c

        Return cards.ToList.AsReadOnly
    End Function
    ''' <summary>
    ''' Obtiene el duelista a partir del prestamo
    ''' </summary>
    ''' <param name="prestamo"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function duelistasPorPrestamo(ByVal prestamo As Prestamo) As ObjectModel.ReadOnlyCollection(Of Duelista)
        Return bd.DuelistaPorPrestamo(prestamo)
    End Function
End Class

Public Class ExisteCartaEventArg
    Inherits EventArgs

    Public Property Carta As Carta

End Class
